***SEES IF POST-2006 TEACHER SHARE IS CORRELATED WITH BEING NEW TO SCHOOL OR DISTRICT
clear all
set mem 2g
set more off
cd "C:\teacher free riding"
log using teacher_share_corr.txt, replace

**MATH***

use "C:\teacher free riding\grade_percentages.dta", clear
keep if year >= 2006
keep if course_type_a == "math"
destring tch_number, replace

	**REPLACE SHARE WITH AVG SHARE ACROSS GRADES**
	collapse (mean) share_students, by(tch_number campus year)

	*DROP TEACHERS IN MULTIPLE CAMPUSES (2%)
	duplicates tag tch_number year, gen(dup)
	tab dup
	drop if dup > 0
	xtset tch_number year
	gen switch_school = l.campus != campus & l.campus != .
	gen enter_hisd = l.campus == .
	reg switch_school share_students, cluster(campus)
	reg enter_hisd share_students, cluster(campus)
	

**ENGLISH***
use "C:\teacher free riding\grade_percentages.dta", clear
keep if year >= 2006
keep if course_type_a == "eng/read"
destring tch_number, replace

	**REPLACE SHARE WITH AVG SHARE ACROSS GRADES**
	collapse (mean) share_students, by(tch_number campus year)

	*DROP TEACHERS IN MULTIPLE CAMPUSES (2%)
	duplicates tag tch_number year, gen(dup)
	tab dup
	drop if dup > 0
	xtset tch_number year
	gen switch_school = l.campus != campus & l.campus != .
	gen enter_hisd = l.campus == .
	reg switch_school share_students, cluster(campus)
	reg enter_hisd share_students, cluster(campus)
	
	
**SCI***
use "C:\teacher free riding\grade_percentages.dta", clear
keep if year >= 2006
keep if course_type_a == "sci"
destring tch_number, replace

	**REPLACE SHARE WITH AVG SHARE ACROSS GRADES**
	collapse (mean) share_students, by(tch_number campus year)

	*DROP TEACHERS IN MULTIPLE CAMPUSES (2%)
	duplicates tag tch_number year, gen(dup)
	tab dup
	drop if dup > 0
	xtset tch_number year
	gen switch_school = l.campus != campus & l.campus != .
	gen enter_hisd = l.campus == .
	reg switch_school share_students, cluster(campus)
	reg enter_hisd share_students, cluster(campus)
	
**SOC***
use "C:\teacher free riding\grade_percentages.dta", clear
keep if year >= 2006
keep if course_type_a == "soc"
destring tch_number, replace

	**REPLACE SHARE WITH AVG SHARE ACROSS GRADES**
	collapse (mean) share_students, by(tch_number campus year)

	*DROP TEACHERS IN MULTIPLE CAMPUSES (2%)
	duplicates tag tch_number year, gen(dup)
	tab dup
	drop if dup > 0
	xtset tch_number year
	gen switch_school = l.campus != campus & l.campus != .
	gen enter_hisd = l.campus == .
	reg switch_school share_students, cluster(campus)
	reg enter_hisd share_students, cluster(campus)

log close
	
			
